package com.xyh;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;

import java.util.Properties;

public class ProducerMain {
    public static void  main(String [] args){
        Properties properties=new Properties();
        properties.put("bootstrap.servers","localhost:9092");
        properties.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
        properties.put("value.serializer","org.apache.kafka.common.serialization.StringSerializer");
        Producer<String,String> producer=new KafkaProducer<String,String>(properties);
        ProducerRecord record=new ProducerRecord<String,String>("my-topic","userName","Angus");
        producer.send(record);
        producer.close();
    }
}
